package me.wangshier.leetcode.easy;

import java.util.Arrays;

/**
 * 13. 构造特定数组的逆序拼接
 *
 * @Author: tongqianwen
 * @Date: 2025/3/6
 */
public class ReverseArray {
    public static int[] solution(int n) {
        int len = n * (n + 1) / 2;
        int[] res = new int[len];
        int index = 0;
        for (int i = 0; i < n; i++) {
            for (int j = n; j > i; j--) {
                res[index++] = j;
            }
        }
        return res;
    }

    public static void main(String[] args) {
        System.out.println(Arrays.equals(solution(3), new int[]{3, 2, 1, 3, 2, 3}));
        System.out.println(Arrays.equals(solution(4), new int[]{4, 3, 2, 1, 4, 3, 2, 4, 3, 4}));
        System.out.println(Arrays.equals(solution(5), new int[]{5, 4, 3, 2, 1, 5, 4, 3, 2, 5, 4, 3, 5, 4, 5}));
    }
}
